import React, { useState } from "react";
import { NavBar, Space, Toast } from "antd-mobile";
import http from "../../api/http";
import { Cell, ProductCard, SubmitBar } from "react-vant";
import { Popup, Button, ResultPage } from "antd-mobile";
function Index() {
  const [visible1, setVisible1] = useState(false);
  const details = [
    {
      label: "收款方",
      value: "张三",
      bold: true,
    },
    {
      label: "付款方式",
      value: "账户余额",
    },
    {
      label: "转账金额",
      value: "¥100.00",
    },
    {
      label: "转账金额",
      value: "¥100.00",
    },
    {
      label: "转账金额",
      value: "¥100.00",
    },
  ];
  const handleSubmit=async()=>{
    const res=await http.get("/api/pay",{
      params:{
        id:1,
        title:"系统购票",
        price:2999,
      }
    })
    const {code,data}=res.data
    if(code===200) window.location.href=data
  }
  return (
    <div>
      <NavBar>确认订单</NavBar>
      <Cell title="支持选择多个收货地址" value="去修改" />
      <ProductCard
        num="2"
        price="79"
        desc="云南白药牙膏清新口气两户白"
        title="商品名称"
        thumb="https://img.yzcdn.cn/vant/ipad.jpeg"
      />
      <Cell title="配送服务" value="现在下单" />
      <Cell title="店铺优惠" value="组合优惠" />
      <Cell title="开具发票" value="本次不具备发票" />
      <Cell title="订单备注" value="无备注" />
      <SubmitBar
        price="168000"
        buttonText="提交订单"
        onSubmit={() => setVisible1(true)}
      />

      <Popup
        visible={visible1}
        onMaskClick={() => {
          setVisible1(false);
        }}
        onClose={() => {
          setVisible1(false);
        }}
        bodyStyle={{ height: "40vh" }}
      >
        <Button block color="primary" size="large" onClick={()=>handleSubmit()}>
          确认付款
        </Button>
        <ResultPage status="" details={details} />
      </Popup>
    </div>
  );
}

export default Index;
